home *** CD-ROM | disk | FTP | other *** search
- head 1.3;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.3
- date 89.10.24.12.37.53; author brent; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.08.26.16.24.30; author brent; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.04.16.12.27.57; author brent; state Exp;
- branches ;
- next ;
-
-
- desc
- @Top level routine for pseudo-device benchmark
- @
-
-
- 1.3
- log
- @Updated to new C library, etc.
- @
- text
- @/*
- * Driver for the new (Dec 87) pseudo-device implementation.
- *
- * The programs output goes to standard out, while the
- * statistics taken go to error output or another file.
- */
-
- #include "sprite.h"
- #include "status.h"
- #include "stdio.h"
- #include "fs.h"
- #include "fsCmd.h"
- #include "sysStats.h"
- #include "rpc.h"
- #include "proc.h"
- #include "vm.h"
- #include "kernel/sched.h"
- #include "kernel/fsStat.h"
- #include "kernel/vm.h"
- #include "option.h"
-
- Boolean useSelect = FALSE;
- Boolean copy = FALSE;
- Boolean readP = FALSE;
- Boolean writeP = FALSE;
- Boolean ioctlP = FALSE;
- Boolean selectP = FALSE;
- Boolean zero = FALSE;
- Boolean switchBuf = FALSE;
- Boolean writeBehind = FALSE;
- int requestBufSize = 2048;
- int size = 128;
- int reps = 10;
- int numClients = -1; /* For multi-program synchronization,
- * this is the number of slaves with
- * which to synchronize */
- int delay = 0; /* Delay loop for server to eat CPU */
- Boolean slave = FALSE;
- extern char *pdev;
-
- Option optionArray[] = {
- {OPT_INT, "srvr", (Address)&numClients,
- "Server for -srvr (int) clients"},
- {OPT_TRUE, "clnt", (Address)&slave,
- "Client process"},
- {OPT_INT, "reps", (Address)&reps,
- "Number of repetitions"},
- {OPT_INT, "size", (Address)&size,
- "Amount of data to transfer"},
- {OPT_TRUE, "selectTest", (Address)&selectP,
- "Select, makes server block client"},
- {OPT_TRUE, "fork", (Address)©,
- "Fork client process (with -clnt)"},
- {OPT_TRUE, "read", (Address)&readP,
- "Read test"},
- {OPT_TRUE, "write", (Address)&writeP,
- "Write test"},
- {OPT_TRUE, "writeBehind", (Address)&writeBehind,
- "Enable write behind (with -srvr)"},
- {OPT_TRUE, "ioctl", (Address)&ioctlP,
- "IOControl test"},
- {OPT_INT, "delay", (Address)&delay,
- "Loop for -delay <int> cylces before replying"},
- {OPT_TRUE, "switchBuf", (Address)&switchBuf,
- "Test switching request buffers (use with -ioctl)"},
- {OPT_STRING, "pdev", (Address)&pdev,
- "Name of the pseudo device"},
- {OPT_INT, "bufsize", (Address)&requestBufSize,
- "Size of the pseudo device request buffer"},
- {OPT_TRUE, "forceSelect", (Address)&useSelect,
- "Make Master use select with 1 client"},
- };
- int numOptions = sizeof(optionArray) / sizeof(Option);
-
- Time startTime, endTime;
- Sched_Instrument startSchedStats, endSchedStats;
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- register ReturnStatus status = SUCCESS;
- Proc_PID child;
- Proc_ResUsage usage;
- FILE *outStream;
- register int i;
- ClientData serverData, clientData;
-
- argc = Opt_Parse(argc, argv, optionArray, numOptions);
- if (!slave && (numClients < 0)) {
- fprintf(stderr, "Server: %s [options] -srvr numClients\n", argv[0]);
- fprintf(stderr, "Client: %s [options] -clnt\n", argv[0]);
- Opt_PrintUsage(argv[0], numOptions, optionArray);
- exit(1);
- }
- /*
- * Check for multi-program master/slave setup.
- */
- if (numClients > 0) {
- ServerSetup(numClients, &serverData);
- slave = FALSE;
- }
- if (slave) {
- ClientSetup(&clientData);
- }
- /*
- * Get first sample of time and idle ticks.
- */
- status = Sys_Stats(SYS_SCHED_STATS, 0, &startSchedStats);
- if (status != SUCCESS) {
- Stat_PrintMsg(status, "Error in Sys_Stats");
- exit(status);
- }
-
- status = Sys_GetTimeOfDay(&startTime, NULL, NULL);
- if (status != SUCCESS) {
- Stat_PrintMsg(status, "Error in Sys_GetTimeOfDay");
- exit(status);
- }
- if (slave) {
- if (copy) {
- status = Proc_Fork(TRUE, &child);
- if (status != PROC_CHILD_PROC && status != SUCCESS) {
- Stat_PrintMsg(status, "Fork failed");
- exit(status);
- }
- }
- if (readP) {
- ClientRead(clientData, size, reps);
- }
- if (writeP) {
- ClientWrite(clientData, size, reps);
- }
- if (ioctlP) {
- ClientIOControl(clientData, size, reps);
- }
- if (copy) {
- if (status != PROC_CHILD_PROC) {
- status = Proc_Wait(0, NULL, TRUE, NULL, NULL, NULL, NULL, &usage);
- } else {
- exit(SUCCESS);
- }
- }
- /*
- * Take ending statistics and print user, system, and elapsed times.
- */
- Sys_GetTimeOfDay(&endTime, NULL, NULL);
- Sys_Stats(SYS_SCHED_STATS, 0, &endSchedStats);
- Time_Subtract(endTime, startTime, &endTime);
- printf("Slave (reps = %d) ", reps);
- PrintTimes(stdout, &usage, &endTime);
-
- ClientDone(clientData);
- /*
- * Print FS statistics.
- */
- } else {
- /*
- * Drop into the top level service loop. ServeOne is a faster
- * version that doesn't use select because there is only
- * one client.
- */
- if (numClients > 1 || useSelect) {
- Serve(serverData);
- } else {
- ServeOne(serverData);
- }
- /*
- * Take ending statistics and print user, system, and elapsed times.
- */
- Sys_GetTimeOfDay(&endTime, NULL, NULL);
- Sys_Stats(SYS_SCHED_STATS, 0, &endSchedStats);
- Time_Subtract(endTime, startTime, &endTime);
- printf("Master: ");
- PrintTimes(stdout, &usage, &endTime);
-
- if (delay > 0) {
- int cnt;
- Sys_GetTimeOfDay(&startTime, NULL, NULL);
- for (cnt=0 ; cnt<50 ; cnt++) {
- for (i=delay<<1 ; i>0 ; i--) ;
- }
- Sys_GetTimeOfDay(&endTime, NULL, NULL);
- Time_Subtract(endTime, startTime, &endTime);
- Time_Divide(endTime, 50, &endTime);
- printf("%d.%06d seconds service delay\n",
- endTime.seconds, endTime.microseconds);
- }
- }
- exit(status);
- }
- @
-
-
- 1.2
- log
- @Added service delay
- @
- text
- @d10 1
- a10 1
- #include "io.h"
- a21 3
- Boolean flushCache = FALSE;
- Boolean clean = FALSE;
- Boolean histogram = FALSE;
- d24 5
- a28 4
- Boolean read = FALSE;
- Boolean write = FALSE;
- Boolean ioctl = FALSE;
- Boolean select = FALSE;
- d31 1
- a38 1
- char *outFile = "pdevtest.out";
- d42 5
- a46 5
- {OPT_INT, 'M', (Address)&numClients,
- "Master for -M (int) clients"},
- {OPT_TRUE, 'S', (Address)&slave,
- "Slave bench program\nTests:"},
- {OPT_INT, 'n', (Address)&reps,
- d48 1
- a48 1
- {OPT_INT, 'd', (Address)&size,
- d50 5
- a54 5
- {OPT_TRUE, 's', (Address)&select,
- "Select, makes master block client"},
- {OPT_TRUE, 'c', (Address)©,
- "Copy stream test, the slave forks"},
- {OPT_TRUE, 'r', (Address)&read,
- d56 1
- a56 1
- {OPT_TRUE, 'w', (Address)&write,
- d58 3
- a60 3
- {OPT_TRUE, 'W', (Address)&writeBehind,
- "Enable write behind (with -M)"},
- {OPT_TRUE, 'i', (Address)&ioctl,
- d62 9
- a70 15
- {OPT_INT, 'P', (Address)&delay,
- "Loop for -P <int> cylces before replying"},
- {OPT_TRUE, 'b', (Address)&switchBuf,
- "Test switching request buffers (use with -i)"},
- {OPT_STRING, 'o', (Address)&outFile,
- "Output file name\n"},
- {OPT_STRING, 'p', (Address)&pdev,
- "Name of the master pseudo device\nTracing:"},
- {OPT_TRUE, 'f', (Address)&flushCache,
- "Flush cache before benchmark"},
- {OPT_TRUE, 'x', (Address)&clean,
- "Turn off all tracing"},
- {OPT_TRUE, 'h', (Address)&histogram,
- "Leave histograms on (ok with -x)"},
- {OPT_TRUE, 'z', (Address)&useSelect,
- a74 2
- FsStats fsStartStats, fsEndStats;
- Vm_Stat vmStartStats, vmEndStats;
- d85 1
- a85 1
- Io_Stream outStream;
- d89 1
- a89 1
- Opt_Parse(&argc, argv, numOptions, optionArray);
- d91 2
- a92 3
- Io_PrintStream(io_StdErr, "Master: %s [-xfpoh] -M numSlaves\n",
- argv[0]);
- Io_PrintStream(io_StdErr, "Slave: %s [-xfpoh] -S\n", argv[0]);
- d94 1
- a94 1
- Proc_Exit(1);
- a95 51
- if (clean) {
- int newValue;
- newValue = 0;
- Fs_Command(FS_SET_CACHE_DEBUG, sizeof(int), &newValue);
- newValue = 0;
- Fs_Command(FS_SET_TRACING, sizeof(int), &newValue);
- newValue = 0;
- Fs_Command(FS_SET_RPC_DEBUG, sizeof(int), &newValue);
- newValue = 0;
- Fs_Command(FS_SET_RPC_TRACING, sizeof(int), &newValue);
- if (!histogram) {
- newValue = 0;
- (void) Fs_Command(FS_SET_RPC_SERVER_HIST, sizeof(int), &newValue);
- newValue = 0;
- (void) Fs_Command(FS_SET_RPC_CLIENT_HIST, sizeof(int), &newValue);
- }
- }
- if (flushCache) {
- int numLockedBlocks = 0;
- Fs_Command(FS_EMPTY_CACHE, sizeof(int), &numLockedBlocks);
- if (numLockedBlocks > 0) {
- Io_PrintStream(io_StdErr, "Flush found %d locked blocks left\n",
- numLockedBlocks);
- }
- }
- outStream = Io_Open(outFile, "w+");
- if (outStream == (Io_Stream)NULL) {
- Io_PrintStream(io_StdErr, "\"%s\": ", outFile);
- Stat_PrintMsg(status, "Can't open");
- Proc_Exit(status);
- }
- /*
- * Copy command line to output file.
- */
- Io_PrintStream(outStream, "%s ", argv[0]);
- if (clean) {
- Io_PrintStream(outStream, "-x ");
- }
- if (histogram) {
- Io_PrintStream(outStream, "-h ");
- }
- if (flushCache) {
- Io_PrintStream(outStream, "-f ");
- }
- if (clean) {
- Io_PrintStream(outStream, "-x ");
- }
- for (i=1 ; i<argc ; i++) {
- Io_PrintStream(outStream, "%s ", argv[i]);
- }
- Io_PrintStream(outStream, "\n");
- d107 1
- a107 1
- * Get first sample of filesystem stats, vm stats, time, and idle ticks.
- a108 10
- status = Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsStartStats);
- if (status != SUCCESS) {
- Stat_PrintMsg(status, "Error getting FS stats");
- Proc_Exit(status);
- }
- status = Vm_Cmd(VM_GET_STATS, &vmStartStats);
- if (status != SUCCESS) {
- Stat_PrintMsg(status, "Error getting VM stats");
- Proc_Exit(status);
- }
- d112 1
- a112 1
- Proc_Exit(status);
- d118 1
- a118 1
- Proc_Exit(status);
- d125 1
- a125 1
- Proc_Exit(status);
- d128 1
- a128 1
- if (read) {
- d131 1
- a131 1
- if (write) {
- d134 1
- a134 1
- if (ioctl) {
- d141 1
- a141 1
- Proc_Exit(SUCCESS);
- d150 2
- a151 2
- Io_PrintStream(io_StdOut, "Slave: ");
- PrintTimes(io_StdOut, &usage, &endTime);
- a152 1
- Sys_Shutdown(0); /* sync cache */
- a153 3
-
- Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsEndStats);
- Vm_Cmd(VM_GET_STATS, &vmEndStats);
- a156 7
- Io_PrintStream(outStream, "C: ");
- PrintIdleTime(outStream, &startSchedStats, &endSchedStats, &endTime);
- PrintFsStats(outStream, &fsStartStats, &fsEndStats);
- /*
- * Print VM statistics.
- */
- PrintVmStats(outStream, &vmStartStats, &vmEndStats);
- d174 2
- a175 16
- Io_PrintStream(io_StdOut, "Master: ");
- PrintTimes(io_StdOut, &usage, &endTime);
-
- Sys_Shutdown(0); /* sync cache */
- Fs_Command(FS_RETURN_STATS, sizeof(FsStats), &fsEndStats);
- Vm_Cmd(VM_GET_STATS, &vmEndStats);
- /*
- * Print FS statistics.
- */
- Io_PrintStream(outStream, "S: ");
- PrintIdleTime(outStream, &startSchedStats, &endSchedStats, &endTime);
- PrintFsStats(outStream, &fsStartStats, &fsEndStats);
- /*
- * Print VM statitistics.
- */
- PrintVmStats(outStream, &vmStartStats, &vmEndStats);
- d186 1
- a186 1
- Io_PrintStream(io_StdOut, "%d.%06d seconds service delay\n",
- d190 1
- a190 2
- Io_Flush(outStream);
- Proc_Exit(status);
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d38 1
- d64 2
- d96 1
- a96 1
- int i;
- d273 13
- @
-